package com.sakiko.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("error")
public class ErrorController {
    /*
    编程式异常处理: 自己写 try-catch
    声明式异常处理:
     */

    // 空指针异常 handler
    @GetMapping("nullPoint")
    public String nullPointException() {
        System.out.println("ErrorController.nullPointException");
        String name = null;
        name.toLowerCase();
        return "nullPointException";
    }

    // 算数异常 handler
    @GetMapping("arithmetic")
    public String arithmeticException() {
        System.out.println("ErrorController.arithmeticException");
        int i = 1 / 0;
        return "arithmeticException";
    }
}
